function setCookie(c_name,value,exdays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie = c_name + "=" + c_value;
}

function getCookie(c_name){
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++){
        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
        x=x.replace(/^\s+|\s+$/g,"");
        if (x==c_name) {
            return unescape(y);
        }
    }
}

function checkCookie(cookieID) {
    /// TODO : load style here
    var style=getCookie(cookieID);

    return style;
    //setCookie("style",username,1);
}

window.GET = function(){
    var array = window.location.search.substring(1).split(/&;/);
        /* URLs can be like either
        "sample.html?test1=hi&test2=bye" or
        "sample.html?test1=hi;test2=bye" */
    window._GET = {};
    for(var i = 0; i < array.length; i++){
        var assign = array[i].indexOf('=');
        if(assign == -1){
            _GET[array[i]] = 1;//if no value, treat as boolean
        }else{
            _GET[array[i].substring(0, assign)] = array[i].substring(assign + 1);
        }
    }
}

style_changer.addEventListener("click", function (){
    style = checkCookie("style");
    if (style == undefined)
        cur_style = 1;
    else
        cur_style = style;
    current_style = document.getElementById("style");
    if (cur_style == 1) {
        current_style.href = "stylesheet/progin2.css";
        cur_style = 0;
    } else {
        current_style.href = "stylesheet/progin.css";
        cur_style = 1;
    }
    setCookie("style", cur_style, 1);
}, false);

style = checkCookie("style");
if (style == undefined || style == null || style == 1)
    document.getElementById("style").href = "stylesheet/progin.css";
else
    document.getElementById("style").href = "stylesheet/progin2.css";